package com.neuedu.his.controller;

import com.neuedu.his.po.Constanttype;
import com.neuedu.his.service.ConstanttypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/constanttype")
public class ConstantTypeController {

    @Autowired
    ConstanttypeService service;


    @RequestMapping("/add")
    public Boolean add(@RequestBody  Constanttype type){
        return service.save(type);
    }

    @RequestMapping("/savetype")
    public boolean savetype(@RequestBody Constanttype constanttype){
        boolean success = service.saveOrUpdate(constanttype);
        return success;
    }


    @RequestMapping("/getBytypeId/{id}")
    public Constanttype getById(@PathVariable Long id){
        Constanttype constanttype = service.getById(id);
        return constanttype;
    }

    @RequestMapping("/deleteBytypeId/{id}")
    public boolean deleteById(@PathVariable String id){
        boolean success = service.removeById(id);
        return success;
    }


    @RequestMapping("/list")
    public List<Constanttype> list(){
        return service.list();
    }
}
